/******************************************************************************
	This file is a part of the Snapshot Bioinformatics Project

	Copyright (C) 2012-2013 Jarom Schow

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include "SnapshotInfoDlg.h"

#include <QtCore/QCoreApplication>

#include <QtWidgets/QTextEdit>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QPushButton>

#include "SnapshotUI.h"
#include "SnapshotTree.h"
#include "SnapshotGeneCollection.h"

/**
**/
SnapshotInfoDlg::SnapshotInfoDlg( SnapshotUI *parent ) : QDialog( parent ), m_ui( parent )
{
	setWindowTitle( tr( "Information" ) );

	initLayout();
	setInfo();
}

/**
**/
SnapshotInfoDlg::~SnapshotInfoDlg()
{
}

/**
**/
void SnapshotInfoDlg::accept()
{
	QDialog::accept();
}

/**
**/
void SnapshotInfoDlg::initLayout()
{
	QVBoxLayout	*layout = new QVBoxLayout;

	setLayout( layout );

	m_infoEdit = new QTextEdit( this );
	layout->addWidget( m_infoEdit );

	QHBoxLayout	*btnLayout = new QHBoxLayout;
	QPushButton	*btn;

	layout->addLayout( btnLayout );

	btnLayout->setMargin( 0 );
	btnLayout->addStretch( 100 );

	btn = new QPushButton( tr( "Ok" ), this );
	connect( btn, SIGNAL(clicked()), this, SLOT(accept()) );
	btnLayout->addWidget( btn );

	btn = new QPushButton( tr( "Cancel" ), this );
	connect( btn, SIGNAL(clicked()), this, SLOT(reject()) );
	btnLayout->addWidget( btn );
}

/**
**/
void SnapshotInfoDlg::setInfo()
{
	if( !m_ui )
		return;

	SnapshotTree			*tree = m_ui->getTaxonomy();
	SnapshotGeneCollection	*genes = m_ui->getGenes();

	m_infoEdit->append( QString( "Number of species: %1" ).arg( tree->getNumSpecies() ) );
	m_infoEdit->append( QString( "Number of genes: %1" ).arg( genes->getNumGenes() ) );
	m_infoEdit->append( QString( "Number of sequences: %1" ).arg( genes->getNumSequences() ) );

}